<?php
//从Bmob中取数据
include_once 'BmobObject.class.php';

$record_diff = new BmobObject('record_diff');

$res = $record_diff->get("", array('limit=0','count=1'));
$count = $res->count; //统计出profit的总条数
//分页，每页1000条，如有多余页，则将其单做一页
$pages = intval(floor($count/1000));
if ($count%1000 != 0) {
	$pages = $pages + 1;
}
$results = [];
for ($i=0; $i < $pages; $i++) {
	$skip = $i * 1000;
	$res = $record_diff->get("", array('$res=$bmobObj->get("",array("keys=datetime,diffOpenInPercent,diffCloseInPercent"))', 'order=datetime', 'limit=1000', "skip=$skip"));
	$array = json_decode(json_encode($res->results),TRUE);
	$results = array_merge($results, $array);
}
$datetime = array();
$diffOpenInPercent = array();
$diffCloseInPercent = array();
foreach($results as $item){
    $datetime[] = $item['datetime'];
    $diffOpenInPercent[] = $item['diffOpenInPercent'];
    $diffCloseInPercent[] = $item['diffCloseInPercent'];
}
file_put_contents('../data/result.json', json_encode(array($datetime, $diffOpenInPercent, $diffCloseInPercent)));
